/* Copyright (c) 2021-2025 Qualcomm Technologies International, Ltd. */
/* %%version */

#include "csr_synergy.h"

#ifndef EXCLUDE_GATT_XPAN_CLIENT_MODULE

#include "gatt_xpan_client.h"
#include "gatt_xpan_client_debug.h"
#include "gatt_xpan_client_private.h"
#include "gatt_xpan_client_read.h"
#include "gatt_xpan_client_common.h"

extern gatt_xpan_client *xpanClientMain;
/*******************************************************************************/
static void gattXpanClientHandleReadRequest(const GXPANC *xpanClient,
                                            uint16 handle)
{
    /* Check parameters */
    if (xpanClient)
    {
        MAKE_XPAN_CLIENT_INTERNAL_MESSAGE(XPAN_CLIENT_INTERNAL_MSG_READ);

        message->serviceHandle = xpanClient->srvcElem->service_handle;
        message->handle = handle;

        XpanClientMessageSend(xpanClientMain->lib_task,
                              XPAN_CLIENT_INTERNAL_MSG_READ,
                              message);
    }
    else
    {
        GATT_XPAN_CLIENT_PANIC("Invalid XPAN Client instance!\n");
    }
}

/*******************************************************************************/
static void gattXpanClientHandleReadRequestCcc(const GXPANC *xpanClient,
                                               uint16 handle)
{
    /* Check parameters */
    if (xpanClient)
    {
        MAKE_XPAN_CLIENT_INTERNAL_MESSAGE(XPAN_CLIENT_INTERNAL_MSG_READ_CCC);

        message->serviceHandle = xpanClient->srvcElem->service_handle;
        message->handle = handle;

        XpanClientMessageSend(xpanClientMain->lib_task,
                              XPAN_CLIENT_INTERNAL_MSG_READ_CCC,
                              message);
    }
    else
    {
        GATT_XPAN_CLIENT_PANIC("Invalid XPAN Client instance!\n");
    }
}

static void gattXpanClientReadRequest(ServiceHandle serviceHandle, XpanClientCharacteristicId charId, XpanClientCharType readType)
{
    GXPANC *gattXpanClient = ServiceHandleGetInstanceData(serviceHandle);
    uint16 handle = 0;

    if (gattXpanClient)
    {
        if (xpanClientGetHandle(gattXpanClient, charId, &handle, readType))
        {
            if (readType == XPAN_CLIENT_CHAR_TYPE_CHARACTERISTIC)
            {
                if (charId != GATT_XPAN_CLIENT_XPAN_CONTROL_POINT)         /* CONTROL POINT is not readable */
                    /* Note: The Request wifi scan_results is not readable either, but the
                     * server should handle the read request correctly so it's being allowed through */
                    gattXpanClientHandleReadRequest(gattXpanClient, handle);
            }
            else if (readType == XPAN_CLIENT_CHAR_TYPE_CHARACTERISTIC_CLIENT_CONFIG)
            {
                gattXpanClientHandleReadRequestCcc(gattXpanClient, handle);
            }
            else
            {
                GATT_XPAN_CLIENT_WARNING("Invalid XPAN Characteristic Read Type\n");
            }
        }
    }
    else
    {
        GATT_XPAN_CLIENT_PANIC("Invalid XPAN Client instance!\n");
    }
}

void GattXpanClientReadRequest(ServiceHandle serviceHandle, XpanClientCharacteristicId charId)
{
    gattXpanClientReadRequest(serviceHandle, charId, XPAN_CLIENT_CHAR_TYPE_CHARACTERISTIC);
}

void GattXpanClientReadRequestCcc(ServiceHandle serviceHandle, XpanClientCharacteristicId charId)
{
    gattXpanClientReadRequest(serviceHandle, charId, XPAN_CLIENT_CHAR_TYPE_CHARACTERISTIC_CLIENT_CONFIG);
}

/*******************************************************************************/
static void xpanSendReadStoredSsidCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 sizeValue,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadStoredSsidsCfm);

    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeStoredSsid(&message->storedSsid, sizeValue, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_STORED_SSIDS_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadIpv4AddressCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadIpAddressCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeIpAddressData(&message->ipAddressData,
                        size_value,
                        value,
                        XPAN_CLIENT_IPV4_ADDRESS_LENGTH_OCTETS);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_IPV4_ADDRESS_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadIpv6AddressCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadIpAddressCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeIpAddressData(&message->ipAddressData,
                        size_value,
                        value,
                        XPAN_CLIENT_IPV6_ADDRESS_LENGTH_OCTETS);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_IPV6_ADDRESS_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadL2capTcpPortCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadL2capTcpPortCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeL2capTcpPort(&message->l2capTcpPort, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_L2CAP_TCP_PORT_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadUdpPortCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadUdpPortCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeUdpPort(&message->udpPort, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_UDP_PORT_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadMDnsSrvUuidCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    const uint8* dataPtr = value;
    const uint8* lastPtr = value + size_value;

    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadMDnsSrvUuidCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientBufferFixedLengthDecode(message->mDnsSvrUuid,
                                      XPAN_CLIENT_MDNS_SRV_UUID_LENGTH_OCTETS,
                                      &dataPtr,
                                      lastPtr);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_MDNS_SRV_UUID_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadTwtConfigurationCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadTwtConfigurationCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeTwtConfiguration(&message->twtConfiguration, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_TWT_CONFIGURATION_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadConnectedDevicesCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadConnectedDevicesCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeConnectedDevices(&message->xpanConnectedDevices, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_CONNECTED_DEVICES_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadClearToSendCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadClearToSendCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeClearToSend(&message->clearToSend, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_CLEAR_TO_SEND_CFM, message);
}

/*******************************************************************************
 * The Control Point Char is not readable
 *
void xpanSendReadXpanControlPointCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
 *******************************************************************************/

/*******************************************************************************/
static void xpanSendReadBearerPreferenceCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadBearerPreferenceCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeBearerPreference(&message->bearerPreference, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_BEARER_PREFERENCE_CFM, message);
}


/*******************************************************************************/
static void xpanSendReadMacAddressCfm(GXPANC * xpanClient,
                               status_t status,
                               uint16 size_value,
                               const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadMacAddressCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeMacAddresses(&message->macAddresses, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_MAC_ADDRESS_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadRequestedSapPowerStateCfm(GXPANC * xpanClient,
                                                  status_t status,
                                                  uint16 size_value,
                                                  const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadRequestedSapPowerStateCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeRequestedSapPowerState(&message->sapPowerStateData, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_REQUESTED_SAP_POWER_STATE_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadServerFeaturesCfm(GXPANC * xpanClient,
                                          status_t status,
                                          uint16 size_value,
                                          const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadServerFeaturesCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeServerFeatures(&message->serverFeatures, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_SERVER_FEATURES_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadAudioBearerSwitchResponseCfm(GXPANC * xpanClient,
                                                     status_t status,
                                                     uint16 size_value,
                                                     const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadAudioBearerSwitchResponseCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeAudioBearerSwitchResponse(&message->audioBearerSwitchResponse, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_AUDIO_BEARER_SWITCH_RESPONSE_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadNumDevicesPresentCfm(GXPANC * xpanClient,
                                            status_t status,
                                            uint16 size_value,
                                            const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadNumDevicesPresentCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeNumDevicesPresent(&message->numDevices, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_NUM_DEVICES_PRESENT_CFM, message);
}

/*******************************************************************************/
static void xpanSendReadVoiceBackChannelPeriodicityCfm(GXPANC * xpanClient,
                                                     status_t status,
                                                     uint16 size_value,
                                                     const uint8 *value)
{
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadVoiceBackChannelPeriodicityCfm);
    message->srvcHndl = xpanClient->srvcElem->service_handle;
    message->status = status;

    xpanClientDecodeVoiceBackChannelPeriodicity(&message->periodicity, size_value, value);

    XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_VOICE_BACK_CHANNEL_PERIODICITY_CFM, message);
}

/*******************************************************************************/
static void xpanClientSendReadCccCfm(GXPANC *gattXpanClient,
                                     status_t status,
                                     uint16 size_value,
                                     const uint8 *value,
                                     GattXpanClientMessageId id)
{
    /* We will use GattXpanClientGenericReadCccCfm to create the message
     * because the structure of all the CCC read confirmations is the same,
     * but we will send the right message using the id parameter */
    MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientGenericReadCccCfm);

    message->srvcHndl = gattXpanClient->srvcElem->service_handle;
    message->status = status;
    message->sizeValue = size_value;

    SynMemMoveS(message->value, XPAN_CLIENT_READ_CCC_VALUE_SIZE, value, size_value);

    XpanClientMessageSend(gattXpanClient->app_task, id, message);
}

/****************************************************************************/
void xpanClientHandleReadValueResp(GXPANC *xpanClient, const CsrBtGattReadCfm *read_cfm)
{
    if (read_cfm->handle == xpanClient->handles.storedSsidHandle)
    {
        /* Send read storedSsidCfm message to application */
        xpanSendReadStoredSsidCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.Ipv4AddressHandle)
    {
        /* Send read Ipv4AddressCfm message to application */
        xpanSendReadIpv4AddressCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.Ipv6AddressHandle)
    {
        /* Send read Ipv6AddressCfm message to application */
        xpanSendReadIpv6AddressCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.L2capTcpPortHandle)
    {
        /* Send read L2capTcpPortCfm message to application */
        xpanSendReadL2capTcpPortCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.UdpPortHandle)
    {
        /* Send read UdpPortCfm message to application */
        xpanSendReadUdpPortCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.MDnsSrvUuidHandle)
    {
        /* Send read MDnsSrvUuidCfm message to application */
        xpanSendReadMDnsSrvUuidCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.TwtConfigurationHandle)
    {
        /* Send read TwtConfigurationCfm message to application */
        xpanSendReadTwtConfigurationCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.ConnectedDevicesHandle)
    {
        /* Send read ConnectedDevicesCfm message to application */
        xpanSendReadConnectedDevicesCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.ClearToSendHandle)
    {
        /* Send read ClearToSendCfm message to application */
        xpanSendReadClearToSendCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.BearerPreferenceHandle)
    {
        /* Send read BearerPreferenceCfm message to application */
        xpanSendReadBearerPreferenceCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.MacAddressHandle)
    {
        /* Send read MacAddressCfm message to application */
        xpanSendReadMacAddressCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.RequestedSapPowerStateHandle)
    {
        /* Send read RequestedSapPowerStateCfm message to application */
        xpanSendReadRequestedSapPowerStateCfm(xpanClient,
                                  read_cfm->resultCode,
                                  read_cfm->valueLength,
                                  read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.serverFeaturesHandle)
    {
        /* Send read ServerFeaturesCfm message to application */
        xpanSendReadServerFeaturesCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.audioBearerSwitchResponseHandle)
    {
        /* Send read AudioBearerSwitchResponseCfm message to application */
        xpanSendReadAudioBearerSwitchResponseCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.numDevicesPresentHandle)
    {
        /* Send read AudioBearerSwitchResponseCfm message to application */
        xpanSendReadNumDevicesPresentCfm(xpanClient,
                                       read_cfm->resultCode,
                                       read_cfm->valueLength,
                                       read_cfm->value);
    }
    else if (read_cfm->handle == xpanClient->handles.voiceBackChannelPeriodicityHandle)
    {
        /* Send read AudioBearerSwitchResponseCfm message to application */
        xpanSendReadVoiceBackChannelPeriodicityCfm(xpanClient,
                                                   read_cfm->resultCode,
                                                   read_cfm->valueLength,
                                                   read_cfm->value);
    }
    /*
     * This characteristic is not readable - but for test purposes, make sure the server returns the correct error code.
     */
    else if (read_cfm->handle == xpanClient->handles.requestWiFiScanResultsHandle)
    {
        /*
         * This is for test purposes only:
         * Send read RequestWifiScanResultsCfm message to application
         */
        MAKE_XPAN_CLIENT_MESSAGE(GattXpanClientReadXpanErrorCfm);
        message->srvcHndl = xpanClient->srvcElem->service_handle;
        message->status = read_cfm->resultCode;

        XpanClientMessageSend(xpanClient->app_task, GATT_XPAN_CLIENT_READ_REQUEST_WIFI_SCAN_RESULTS_CFM, message);

    }
    else if (read_cfm->handle == xpanClient->handles.storedSsidCccHandle)
    {
        /* Send read StoredSsidCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_STORED_SSID_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.Ipv4AddressCccHandle)
    {
        /* Send read Ipv4AddressCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_IPV4_ADDRESS_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.Ipv6AddressCccHandle)
    {
        /* Send read Ipv6AddressCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_IPV6_ADDRESS_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.L2capTcpPortCccHandle)
    {
        /* Send read L2capTcpPortCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_L2CAP_TCP_PORT_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.UdpPortCccHandle)
    {
        /* Send read UdpPortCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_UDP_PORT_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.ConnectedDevicesCccHandle)
    {
        /* Send read ConnectedDevicesCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_CONNECTED_DEVICES_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.ClearToSendCccHandle)
    {
        /* Send read ClearToSendCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_CLEAR_TO_SEND_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.BearerPreferenceCccHandle)
    {
        /* Send read BearerPreferenceCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_BEARER_PREFERENCE_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.MacAddressCccHandle)
    {
        /* Send read MacAddressCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_MAC_ADDRESS_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.RequestedSapPowerStateCccHandle)
    {
        /* Send read RequestedSapPowerStateCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_REQUESTED_SAP_POWER_STATE_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.serverFeaturesCccHandle)
    {
        /* Send read ServerFeaturesCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_SERVER_FEATURES_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.audioBearerSwitchResponseCccHandle)
    {
        /* Send read AudioBearerSwitchResponseCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_AUDIO_BEARER_SWITCH_RESPONSE_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.numDevicesPresentCccHandle)
    {
        /* Send read NumDevicesPresentCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_NUM_DEVICES_PRESENT_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.voiceBackChannelPeriodicityCccHandle)
    {
        /* Send read VoiceBackChannelPeriodicityCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_VOICE_BACK_CHANNEL_PERIODICITY_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.requestWiFiScanResultsCccHandle)
    {
        /* Send read RequestWifiScanResultsCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_REQUEST_WIFI_SCAN_RESULTS_CCC_CFM);
    }
    else if (read_cfm->handle == xpanClient->handles.roamingRequestResponseCccHandle)
    {
        
        /* Send read RoamingRequestResponseCccCfm message to application */
        xpanClientSendReadCccCfm(xpanClient,
                           read_cfm->resultCode,
                           read_cfm->valueLength,
                           read_cfm->value,
                           GATT_XPAN_CLIENT_READ_ROAMING_REQUEST_RESPONSE_CCC_CFM);
    }
}

#endif /* EXCLUDE_GATT_XPAN_CLIENT_MODULE */